<template>
    <div>
        <table class="table table-bordered">
            <tr>
                <td>用户名</td>
                <td><input type="text" v-model="add.name"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="add.pwd"></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" @click="ok" value="注册"></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref, reactive, onMounted, pushScopeId } from "vue";
import moment from 'moment';
import { useRouter, useRoute } from "vue-router";
const router = useRouter();
const route = useRoute();

let add: any = reactive(
    {
        "name": "",
        "pwd": ""
    }
)
const ok = () => {
    axios({
        url: 'https://localhost:7207/api/Emp/addlogin',
        method: 'post',
        data: add
    })
        .then(res => {
            console.log(res);
            if (res.data == -1) {
                alert("用户名重复");
                return;
            }
            else {
                alert("注册成功");
                router.push("/Login");
            }
        })
        .catch(err => {
            console.log(err);

        })
}
</script>

<style scoped></style>